package com.tuliomoura.got.guide;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockFragment;

public class HousesFragment extends SherlockFragment
{
	private GridView gridView;
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
	}
	
	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
	{
		gridView = (GridView) inflater.inflate(R.layout.fragment_houses, container, false);
		gridView.setAdapter(new HousesAdapter(getActivity()));
        return gridView;
    }
	
	private class HousesAdapter extends BaseAdapter
	{
		
		private Context mContext;
		private String[] mHouses;

		public HousesAdapter(Context context)
		{
			mContext = context;
			mHouses = mContext.getResources().getStringArray(R.array.house_array);
		}
		
		public int getCount() 
		{
			return 10;
		}

		public Object getItem(int arg0) 
		{
			return null;
		}

		public long getItemId(int position) 
		{
			return 0;
		}

		public View getView(int position, View convertView, ViewGroup parent) 
		{
			final View v;
			LayoutInflater li = getActivity().getLayoutInflater();
			v = li.inflate(R.layout.house_sigil, null);
			
			TextView name = (TextView) v.findViewById(R.id.house_sigil_name);
			name.setText(mHouses[position]);
			
			ImageView image = (ImageView) v.findViewById(R.id.house_sigil_image);
			image.setImageResource(R.drawable.brasil);

			return v;
		}
		
	}
	
}
